<?php
/**
 * Created by IntelliJ IDEA.
 * User: XD
 * Date: 2017/8/21
 * Time: 9:21
 */

// 升序
$cars = array("Volvo","BMW","Toyota");
sort($cars);
print_r($cars);
echo ("<br>");

$numbers = array(4,6,2,22,11);
sort($numbers);
print_r($numbers);

// 降序
$cars=array("Volvo","BMW","Toyota");
rsort($cars);
print_r($cars);

$numbers=array(4,6,2,22,11);
rsort($numbers);
print_r($numbers);

// asort() - 根据数组的值，对数组进行升序排列
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
asort($age);
print_r($age);

//ksort() - 根据数组的键，对数组进行升序排列
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
ksort($age);
print_r($age);

//arsort() - 根据数组的值，对数组进行降序排列
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
arsort($age);
print_r($age);
//krsort() - 根据数组的键，对数组进行降序排列
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");
krsort($age);
print_r($age);
?>